<template>
    <div class="app-container">
    <div class="eryu-list">
      <div class="eryu-search" ref="eryuseach">
        <el-form
          :model="queryParams"
          ref="queryForm"
          size="small"
          :inline="true"
          v-show="showSearch"
          label-width="72px"
          :style="{ '--label-width': '72px' }"
          @submit.native.prevent
        >
        </el-form>
      </div>

      <div class="eryu-list-op">
        <div class="list-name">流程列表</div>
        <div class="lits-op">
          <!-- <el-button size="mini" @click="handleExport"
            >导出</el-button
          > -->
          <el-button
            type="primary"
            size="mini"
            @click="handleAdd"
            >新建</el-button
          >
        </div>
      </div>

      <el-table v-loading="loading" :data="list" :border="true">
      <el-table-column label="审批编号" align="center" prop="id" width="200" />
      <el-table-column label="主题" align="center" prop="name" width="340" />
      <el-table-column label="发起时间" align="center" prop="processInstance.name"/>
      <el-table-column label="当前审批人" align="center" prop="processInstance.startUserNickname" />
      <el-table-column label="当前节点停留时长" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="完成时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审批状态" align="center" prop="version" width="180">
        <template slot-scope="scope">
          <el-tag type="success" v-if="scope.row.suspensionState === 1">激活</el-tag>
          <el-tag type="warning" v-if="scope.row.suspensionState === 2">挂起</el-tag>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>
      </div>
  </div>
</template>

<script>
import {getTodoTaskPage} from '@/api/bpm/task'
import {listSimpleUsers} from "@/api/system/user";

export default {
  name: "Todo",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 待办任务列表
      list: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        name: null,
        createTime: []
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {

    // 发起流程 
    handleAdd(){
      this.$router.push({path:'/bpm/approval/approval'})
    },

    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      getTodoTaskPage(this.queryParams).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // /** 处理审批按钮 */
    // handleAudit(row) {
    //   this.$router.push({ path: "/bpm/process-instance/detail", query: { id: row.processInstance.id}});
    // },
  }
};
</script>
<style lang="scss" scoped>
  .app-container {
  padding: 24px 24px 0px 24px;

  .eryu-list-op{
    font-size: 18px;
  }
  }
</style>
